package com.uni.domain;

import java.util.ArrayList;
import java.util.List;

public class Course extends Identifier {
    private String name;
    private String info;
    private List<Lection> lections;

    //Course must contain discipline or.. not to be?
    private Discipline discipline;

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public List<Lection> getLections() {
        return lections;
    }
    public void setLections(List<Lection> lections) {
        this.lections = lections;
    }
    public Lection getLection(int id) {
    	if(id < 0 || id >= lections.size()) return null;
        return lections.get(id);
    }
    public void setLection(int id, Lection l) {
        check();
        lections.set(id, l);
    }
    public void addLection(Lection lection) {
        check();
        lections.add(lection);
    }

    public Discipline getDiscipline() {
        return discipline;
    }

    public void setDiscipline(Discipline discipline) {
        this.discipline = discipline;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //todo: probabbly, it must be replaced by some init(), that well be call by spring, hibernate or thimething like this.
    private void check(){
        lections = lections == null ? lections = new ArrayList<Lection>() : lections;
    }
}
